home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1995 November / EnigmA AMIGA RUN 02 (1995)(G.R. Edizioni)(IT)[!][issue 1995-11][Skylink CD].iso / earcd / giochi / aboulder.lha / ABoulderDash1.0 / editor.s < prev    next >
Text File  |  1995-08-27  |  31KB  |  1,830 lines

  1.     opt    L+
  2.     opt    O2+
  3.     opt    OW-
  4.  
  5. *==========================================
  6. *
  7. * File:        editor.s
  8. * Version:     1
  9. * Revision:    0
  10. * Created:     27-VIII-1993
  11. * By:          FNC Slothouber
  12. * Last Update: 25-Aug-1995
  13. * By:          FNC Slothouber
  14. *
  15. *==========================================
  16.  
  17.     incdir    "include:"
  18.  
  19.     include graphics/graphics_lib.i
  20.     include    graphics/view.i
  21.     include    exec/exec_lib.i
  22.     include exec/memory.i
  23.     include exec/nodes.i
  24.     include exec/interrupts.i
  25.     include    libraries/dos_lib.i
  26.     include    libraries/dos.i
  27.     include    ExtGfx.i
  28.     include    reqtools/reqtools_lib.i
  29.     include reqtools/reqtools.i
  30.     include    intuition/intuition_lib.i
  31.     include    intuition/intuition.i
  32.     include    execmacros.i
  33.     include    boulderdash.i
  34.  
  35.     XDEF    Start_Editor
  36.     XDEF    Stop_Editor
  37.     XDEF    Field_Editor
  38.     XDEF    BD_window
  39.  
  40.     XREF    _ExtGfxBase
  41.     XREF    _IntuitionBase
  42.     XREF    _GfxBase
  43.     XREF    _ReqToolsBase
  44.     XREF    _DOSBase
  45.     XREF    bitmap1
  46.     XREF    bitmapg
  47.     XREF    colors
  48.     XREF    Editor_Animate
  49.     XREF    grid_field
  50.     XREF    test_field
  51.     XREF    Play
  52.     XREF    Editor_Draw_One_Object 
  53.     XREF    integer_time
  54.     XREF    integer_target
  55.     XREF    integer_score
  56.  
  57.     XREF    AllocRasters
  58.     XREF    FreeRasters
  59.     XREF    EG_AllocBitMap
  60.     XREF    EG_FreeBitMap
  61.     XREF    GetPicture
  62.     XREF    ClearBitMap
  63.     XREF    GetDisplay
  64.     XREF    FreeDisplay
  65.     XREF    CreatePort
  66.     XREF    DeletePort
  67.     XREF    CreateStdIO
  68.     XREF    CreateExtIO
  69.     XREF    DeleteStdIO
  70.     XREF    DeleteExtIO
  71.  
  72. CALLEXT        macro
  73.         jsr    \1
  74.         endm
  75.  
  76.  
  77. GADGET_OFFSET    equ    12
  78. GAME_FILE_SIZE    equ    GRIDF_HEIGHT*GRIDF_WIDTH+4+4+2+2
  79.  
  80. *
  81. * Start_Editor - Open Screen and window for the editor
  82. *
  83. *
  84.  
  85. Start_Editor
  86.     lea    BD_newscreen,a0
  87.     move.l    bitmap1,ns_CustomBitMap(a0)
  88.     INTCALL    OpenScreen
  89.     move.l    d0,BD_screen
  90.     beq    .error
  91.     lea    BD_newwindow,a0
  92.     move.l    d0,nw_Screen(a0)
  93.     INTCALL    OpenWindow
  94.     move.l    d0,BD_window
  95.     beq    .error
  96.  
  97. * Set Colors
  98.     lea    colors,a2
  99.     moveq    #NUM_COLORS-1,d4
  100.     moveq    #0,d5
  101. .loop1
  102.     move.l    d5,d0
  103.     addq.l    #1,d5
  104.     moveq    #0,d1
  105.     move.w    (a2)+,d1    Get RGB value
  106.     move.l    d1,d2        copy G to d2
  107.     move.l    d1,d3        copy B to d3
  108.     lsr.w    #8,d1        Get them in the right place
  109.     lsr.w    #4,d2
  110.         and.w   #$F,d1
  111.     and.w    #$F,d2
  112.     and.w    #$F,d3
  113.     move.l    BD_screen,a0
  114.     add.l    #sc_ViewPort,a0
  115.     GRAFCALL SetRGB4
  116.     dbra    d4,.loop1
  117.     bsr    Display_Gadgets_Images
  118.  
  119. * Init Menus
  120.  
  121.     move.l    BD_window,a0
  122.     lea    menu1,a1
  123.     INTCALL    SetMenuStrip
  124.  
  125. * Allocate File Requesters
  126. * PLAY
  127.     move.l    #RT_FILEREQ,d0
  128.     sub.l    a0,a0
  129.     CALLREQT rtAllocRequestA
  130.     move.l    d0,play_file_requester
  131.     beq    .error
  132.     lea    play_dir_tags,a0
  133.     move.l    play_file_requester,a1
  134.     CALLREQT rtChangeReqAttrA
  135. * LOAD SAVE
  136.     move.l    #RT_FILEREQ,d0
  137.     sub.l    a0,a0
  138.     CALLREQT rtAllocRequestA
  139.     move.l    d0,loadsave_file_requester
  140.     beq    .error
  141.     lea    wild_tags,a0
  142.     move.l    loadsave_file_requester,a1
  143.     CALLREQT rtChangeReqAttrA
  144.  
  145.     moveq    #0,d0
  146.     bra    .exit
  147. .error    moveq    #-1,d0
  148. .exit    rts
  149.  
  150.  
  151. *
  152. * Display_Gadgets_Images - Copy gadget graphics from graphics bitmap to
  153. *                          screen bitmap.
  154. *
  155.  
  156.  
  157. Display_Gadgets_Images
  158.     move.l    bitmap1,a0
  159.     CALLEXT ClearBitMap
  160.  
  161.     move.l    bitmapg,a0
  162.     add.l    #bm_Planes,a0
  163.     move.l    bitmap1,a1
  164.     add.l    #bm_Planes,a1
  165.  
  166.     move.w    #BM_d-1,d0
  167. .loop1    move.l    (a0)+,a2        Source
  168.     move.l    (a1)+,a3        Dest
  169.     add.l    #IM_GADGETS,a2
  170.     add.l    #GADGET_OFFSET*(BM_x/8),a3    make room for screen title bar
  171.     move.w    #32-1,d1
  172. .loop2    move.w    #(BD_SCREEN_x/16)-1,d2
  173. .loop3    move.w    (a2)+,(a3)+
  174.     dbra    d2,.loop3
  175.     add.l    #(BM_x-GRAPHICS_x)/8,a3
  176.     dbra    d1,.loop2
  177.     dbra    d0,.loop1
  178.  
  179.     move.l    BD_screen,a0
  180.     moveq    #-1,d0
  181.     INTCALL ShowTitle
  182.  
  183.     rts
  184.  
  185. *
  186. * Stop_Editor - Close Screen and Window
  187. *
  188. *
  189.  
  190. Stop_Editor
  191.     move.l    loadsave_file_requester,d0
  192.     beq    .ll4
  193.     move.l    d0,a1
  194.     CALLREQT rtFreeRequest
  195. .ll4
  196.     move.l    play_file_requester,d0
  197.     beq    .ll3
  198.     move.l    d0,a1
  199.     CALLREQT rtFreeRequest
  200. .ll3
  201.     move.l    BD_window,d0
  202.     beq    .ll2
  203.     move.l    d0,a0
  204.     INTCALL    ClearMenuStrip
  205.     move.l    BD_window,a0
  206.     INTCALL    CloseWindow
  207. .ll2
  208.     move.l    BD_screen,d0
  209.     beq    .ll1
  210.     move.l    d0,a0
  211.     INTCALL    CloseScreen
  212. .ll1    rts
  213.  
  214.  
  215. *
  216. * Field_Editor -
  217. *
  218. *
  219. *
  220. *
  221.  
  222. Field_Editor ; ()
  223.     move.l    a7,editor_break
  224.  
  225. * Intialize some constants
  226.     move.w    #FALSE,flag_work_dirty
  227.  
  228.     lea    target_data,a1
  229.     move.l    #100,(a1)
  230.     lea    time_data,a1
  231.     move.l    #5000,(a1)
  232.  
  233.     lea    play_filename,a0
  234.     move.b    #0,(a0)
  235.     lea    filename,a0
  236.     move.b    #0,(a0)
  237.  
  238. * Create Grid Field
  239.     move.l    grid_field,a0
  240.     lea    test_field,a1
  241.     bsr    Init_Grid_Field
  242.  
  243.     move.l    #2*grid_sizeof,screen_x
  244.     move.l    #2*grid_sizeof*GRIDF_WIDTH,screen_y
  245.  
  246.     move.w    #0,ted_x
  247.     move.w    #0,ted_y
  248.  
  249. * Show Grid Field
  250.     move.l    grid_field,a2
  251.     add.l    screen_x,a2
  252.     add.l    screen_y,a2
  253.     move.l    bitmap1,a3
  254.     move.l    bitmapg,a4
  255.     add.l    #bm_Planes,a3
  256.     add.l    #bm_Planes,a4
  257.     jsr    Editor_Animate
  258.  
  259. * Set Current Object
  260.     move.w    #TRANS_NONE,CObject_trans
  261.     move.w    #DRAW_ROCK,CObject_draw
  262.     move.w    #G_ROCK,CObject_type
  263.  
  264. * Wait for a message to arrive
  265. .wait    move.l    BD_window,a0
  266.     move.l    wd_UserPort(a0),a0
  267.     moveq    #0,d1
  268.     move.b    MP_SIGBIT(a0),d1
  269.     moveq    #1,d0
  270.     lsl.l    d1,d0
  271.     EXECCALL Wait
  272.  
  273. * One or more messages have arrived. Respond to them
  274. .resp    move.l    BD_window,a0
  275.     move.l    wd_UserPort(a0),a0
  276.     EXECCALL GetMsg
  277.     move.l    d0,a1
  278.     move.l    d0,d1
  279.     beq    .wait
  280.  
  281.     move.l    im_Class(a1),bd_ms_class
  282.     move.w    im_Code(a1),bd_ms_code
  283.     move.l    im_IAddress(a1),bd_ms_iaddress
  284.     move.w    im_MouseX(a1),bd_ms_mousex
  285.     move.w    im_MouseY(a1),bd_ms_mousey
  286.  
  287.     EXECCALL ReplyMsg
  288.  
  289.     move.l    bd_ms_class,d0
  290.  
  291. * User selected a gadget ?
  292.     cmp.l    #GADGETUP,d0
  293.     bne.s    .pos2
  294.  
  295.     move.l    bd_ms_iaddress,a0
  296.     moveq    #0,d0
  297.     move.w    gg_GadgetID(a0),d0
  298.     pea    .next
  299.     bra    gad_table_access
  300.  
  301. * User Pressed a mouse button ?
  302. .pos2    cmp.l    #MOUSEBUTTONS,d0
  303.     bne.s    .pos3
  304.     bsr    proc_mouse
  305.  
  306. * User Pressed a Key
  307. .pos3    cmp.l    #RAWKEY,d0
  308.     bne    .pos4
  309.     move.w    bd_ms_code,d0
  310.     cmp.w    #$4c,d0            Cursor Up
  311.     bne.s    .key2
  312.     bsr    gadget_up
  313.     bra    .next
  314. .key2    cmp.w    #$4d,d0            Cursor Down
  315.     bne.s    .key3
  316.     bsr    gadget_down
  317.     bra    .next
  318. .key3    cmp.w    #$4f,d0            Cursor Left
  319.     bne.s    .key4
  320.     bsr    gadget_left
  321.     bra    .next
  322. .key4    cmp.w    #$4e,d0            Cursor Right
  323.     bne.s    .key5
  324.     bsr    gadget_right
  325.     bra    .next
  326. .key5    cmp.w    #$14,d0            T
  327.     bne.s    .key6
  328.     bsr    gadget_test
  329.     bra    .next
  330. .key6    cmp.w    #$19,d0            P
  331.     bne.s    .key7
  332.     bsr    gadget_play
  333.     bra    .next
  334. .key7    cmp.w    #$10,d0            Q
  335.     bne.s    .key8
  336.     bsr    gadget_quit
  337.     bra    .next
  338. .key8    cmp.w    #$5f,d0            Help Key
  339.     bne    .next
  340.     bsr    gadget_help
  341.     bra    .next
  342.  
  343. * User selected a menu Item ?
  344. .pos4    cmp.l    #MENUPICK,d0
  345.     bne    .pos5
  346.     move.w    bd_ms_code,d0
  347.     move.w    d0,d1
  348.     and.w    #%11111,d0
  349.     lsr.w    #5,d1
  350.     and.w    #%111111,d1
  351. * Project Menu ?
  352.     cmp.w    #MENUProject,d0
  353.     bne.s    .men2
  354.     cmp.w    #ITEMOpen,d1
  355.     bne.s    .item11
  356.     bsr    gadget_load
  357.     bra    .next
  358. .item11    cmp.w    #ITEMClear,d1
  359.     bne.s    .item12
  360.     bsr    gadget_clr
  361.     bra    .next
  362. .item12    cmp.w    #ITEMSave,d1
  363.     bne.s    .item13
  364.     bsr    gadget_save
  365.     bra    .next
  366. .item13    cmp.w    #ITEMQuit,d1
  367.     bne.s    .item14
  368.     bsr    gadget_quit
  369.     bra    .next
  370. .item14    cmp.w    #ITEMHelp,d1
  371.     bne.s    .next
  372.     bsr    gadget_help
  373.     bra    .next
  374. * Game Menu ?
  375. .men2    cmp.w    #MENUGame,d0
  376.     bne.s    .next
  377. .item21    cmp.w    #ITEMPlay,d1
  378.     bne.s    .item22
  379.     bsr    gadget_play
  380.     bra    .next
  381. .item22    cmp.w    #ITEMTest,d1
  382.     bne.s    .item23
  383.     bsr    gadget_test
  384.     bra    .next
  385. .item23    cmp.w    #ITEMTime,d1
  386.     bne.s    .item24
  387.     bsr    gadget_time
  388.     bra    .next
  389. .item24    cmp.w    #ITEMTarget,d1
  390.     bne.s    .next
  391.     bsr    gadget_target
  392.     bra    .next
  393. .pos5    nop
  394. .next    bra    .resp
  395.  
  396.  
  397. ******************
  398. *** Jump Table ***
  399. ******************
  400. gad_table_access
  401.     jmp    gadtabel(pc,d0)
  402. gadtabel
  403.     jmp    gadget_diamond        current object = diamond
  404.     jmp    gadget_ted        current object = ted
  405.     jmp    gadget_brick        current object = brick
  406.     jmp    gadget_border            ""
  407.     jmp    gadget_mover            ""
  408.     jmp    gadget_rock            ""
  409.     jmp    gadget_dirt            ""
  410.     jmp    gadget_empty            ""
  411.     jmp    gadget_butterfly        ""
  412.     jmp    gadget_fungis            ""
  413.     jmp    gadget_fast_left
  414.     jmp    gadget_fast_right
  415.     jmp    gadget_fast_up
  416.     jmp    gadget_fast_down
  417.     jmp    gadget_left
  418.     jmp    gadget_right
  419.     jmp    gadget_up
  420.     jmp    gadget_down
  421.     jmp    gadget_play
  422.     jmp    gadget_test
  423.     jmp    gadget_load
  424.     jmp    gadget_save
  425.     jmp    gadget_clr
  426.     jmp    gadget_quit
  427.     jmp    gadget_time
  428.     jmp    gadget_target
  429.     jmp    gadget_help
  430.     jmp    gadget_exit
  431.     jmp    gadget_dummy            for safety
  432.     jmp    gadget_dummy
  433.     jmp    gadget_dummy
  434.     jmp    gadget_dummy
  435.  
  436.  
  437. *
  438. * gadget_diamond
  439. *
  440. *
  441.  
  442. gadget_diamond
  443.     move.w    #DRAW_DIAMOND,CObject_draw
  444.     move.w    #TRANS_NONE,CObject_trans
  445.     move.w    #G_DIAMOND,CObject_type
  446.     rts
  447.  
  448. *
  449. * gadget_ted
  450. *
  451. *
  452.  
  453. gadget_ted
  454.     move.w    #DRAW_TED,CObject_draw
  455.     move.w    #TRANS_NONE,CObject_trans
  456.     move.w    #G_TED,CObject_type
  457.     rts
  458.  
  459. *
  460. * gadget_brick
  461. *
  462. *
  463.  
  464. gadget_brick
  465.     move.w    #DRAW_BRICK,CObject_draw
  466.     move.w    #TRANS_NONE,CObject_trans
  467.     move.w    #G_BRICK,CObject_type
  468.     rts
  469.  
  470. *
  471. * gadget_border
  472. *
  473. *
  474.  
  475. gadget_border
  476.     move.w    #DRAW_BORDER,CObject_draw
  477.     move.w    #TRANS_NONE,CObject_trans
  478.     move.w    #G_BORDER,CObject_type
  479.     rts
  480.  
  481. *
  482. * gadget_mover
  483. *
  484. *
  485.  
  486. gadget_mover
  487.     move.w    #DRAW_MOVER,CObject_draw
  488.     move.w    #TRANS_NONE,CObject_trans
  489.     move.w    #G_MOVER,CObject_type
  490.     rts
  491.  
  492. *
  493. * gadget_rock
  494. *
  495. *
  496.  
  497. gadget_rock
  498.     move.w    #DRAW_ROCK,CObject_draw
  499.     move.w    #TRANS_NONE,CObject_trans
  500.     move.w    #G_ROCK,CObject_type
  501.     rts
  502.  
  503. *
  504. * gadget_dirt
  505. *
  506. *
  507.  
  508. gadget_dirt
  509.     move.w    #DRAW_DIRT,CObject_draw
  510.     move.w    #TRANS_NONE,CObject_trans
  511.     move.w    #G_DIRT,CObject_type
  512.     rts
  513.  
  514. *
  515. * gadget_empty
  516. *
  517. *
  518.  
  519. gadget_empty
  520.     move.w    #DRAW_EMPTY,CObject_draw
  521.     move.w    #TRANS_NONE,CObject_trans
  522.     move.w    #G_EMPTY,CObject_type
  523.     rts
  524.  
  525. *
  526. * gadget_butterfly
  527. *
  528. *
  529.  
  530. gadget_butterfly
  531.     move.w    #DRAW_BUTTERFLY,CObject_draw
  532.     move.w    #TRANS_NONE,CObject_trans
  533.     move.w    #G_BUTTERFLY,CObject_type
  534.     rts
  535.  
  536. *
  537. * gadget_fungis
  538. *
  539. *
  540.  
  541. gadget_fungis
  542.     move.w    #DRAW_FUNGIS,CObject_draw
  543.     move.w    #TRANS_NONE,CObject_trans
  544.     move.w    #G_FUNGIS,CObject_type
  545.     rts
  546.  
  547. *
  548. * gadget_exit
  549. *
  550. *
  551.  
  552. gadget_exit
  553.     move.w    #DRAW_EXIT,CObject_draw
  554.     move.w    #TRANS_NONE,CObject_trans
  555.     move.w    #G_EXIT,CObject_type
  556.     rts
  557.  
  558.  
  559. *
  560. * gadget_fast_left
  561. *
  562. *
  563.  
  564. gadget_fast_left
  565.     move.l    #EDIT_SCROLL_LEFT_MAX,d0
  566.     move.l    d0,screen_x
  567.  
  568.     move.l    grid_field,a2
  569.     add.l    screen_x,a2
  570.     add.l    screen_y,a2
  571.     move.l    bitmap1,a3
  572.     move.l    bitmapg,a4
  573.     add.l    #bm_Planes,a3
  574.     add.l    #bm_Planes,a4
  575.     jsr    Editor_Animate
  576.     rts
  577.  
  578. *
  579. * gadget_fast_right
  580. *
  581. *
  582.  
  583. gadget_fast_right
  584.     move.l    #EDIT_SCROLL_RIGHT_MAX,d0
  585.     move.l    d0,screen_x
  586.     move.l    grid_field,a2
  587.     add.l    screen_x,a2
  588.     add.l    screen_y,a2
  589.     move.l    bitmap1,a3
  590.     move.l    bitmapg,a4
  591.     add.l    #bm_Planes,a3
  592.     add.l    #bm_Planes,a4
  593.     jsr    Editor_Animate
  594.     rts
  595.  
  596. *
  597. * gadget_fast_up
  598. *
  599. *
  600.  
  601. gadget_fast_up
  602.     move.l    #EDIT_SCROLL_UP_MAX,d0
  603.     move.l    d0,screen_y
  604.     move.l    grid_field,a2
  605.     add.l    screen_x,a2
  606.     add.l    screen_y,a2
  607.     move.l    bitmap1,a3
  608.     move.l    bitmapg,a4
  609.     add.l    #bm_Planes,a3
  610.     add.l    #bm_Planes,a4
  611.     jsr    Editor_Animate
  612.     rts
  613.  
  614. *
  615. * gadget_fast_down
  616. *
  617. *
  618.  
  619. gadget_fast_down
  620.     move.l    #EDIT_SCROLL_DOWN_MAX,d0
  621.     move.l    d0,screen_y
  622.     move.l    grid_field,a2
  623.     add.l    screen_x,a2
  624.     add.l    screen_y,a2
  625.     move.l    bitmap1,a3
  626.     move.l    bitmapg,a4
  627.     add.l    #bm_Planes,a3
  628.     add.l    #bm_Planes,a4
  629.     jsr    Editor_Animate
  630.     rts
  631.  
  632. *
  633. * gadget_left
  634. *
  635. *
  636.  
  637. gadget_left
  638.     move.l    screen_x,d0
  639.     cmp.l    #EDIT_SCROLL_LEFT_MAX,d0
  640.     beq    .exit
  641.     subq.l    #grid_sizeof,d0
  642.     move.l    d0,screen_x
  643.  
  644.     move.l    grid_field,a2
  645.     add.l    screen_x,a2
  646.     add.l    screen_y,a2
  647.     move.l    bitmap1,a3
  648.     move.l    bitmapg,a4
  649.     add.l    #bm_Planes,a3
  650.     add.l    #bm_Planes,a4
  651.     jsr    Editor_Animate
  652. .exit    rts
  653.  
  654. *
  655. * gadget_right
  656. *
  657. *
  658.  
  659. gadget_right
  660.     move.l    screen_x,d0
  661.     cmp.l    #EDIT_SCROLL_RIGHT_MAX,d0
  662.     beq    .exit
  663.     addq.l    #grid_sizeof,d0
  664.     move.l    d0,screen_x
  665.  
  666.     move.l    grid_field,a2
  667.     add.l    screen_x,a2
  668.     add.l    screen_y,a2
  669.     move.l    bitmap1,a3
  670.     move.l    bitmapg,a4
  671.     add.l    #bm_Planes,a3
  672.     add.l    #bm_Planes,a4
  673.     jsr    Editor_Animate
  674. .exit    rts
  675.  
  676. *
  677. * gadget_up
  678. *
  679. *
  680.  
  681. gadget_up
  682.     move.l    screen_y,d0
  683.     cmp.l    #EDIT_SCROLL_UP_MAX,d0
  684.     beq    .exit
  685.     sub.l    #grid_sizeof*GRIDF_WIDTH,d0
  686.     move.l    d0,screen_y
  687.  
  688.     move.l    grid_field,a2
  689.     add.l    screen_x,a2
  690.     add.l    screen_y,a2
  691.     move.l    bitmap1,a3
  692.     move.l    bitmapg,a4
  693.     add.l    #bm_Planes,a3
  694.     add.l    #bm_Planes,a4
  695.     jsr    Editor_Animate
  696.  
  697. .exit    rts
  698.  
  699. *
  700. * gadget_down
  701. *
  702. *
  703.  
  704. gadget_down
  705.     move.l    screen_y,d0
  706.     cmp.l    #EDIT_SCROLL_DOWN_MAX,d0
  707.     beq    .exit
  708.     add.l    #grid_sizeof*GRIDF_WIDTH,d0
  709.     move.l    d0,screen_y
  710.  
  711.     move.l    grid_field,a2
  712.     add.l    screen_x,a2
  713.     add.l    screen_y,a2
  714.     move.l    bitmap1,a3
  715.     move.l    bitmapg,a4
  716.     add.l    #bm_Planes,a3
  717.     add.l    #bm_Planes,a4
  718.     jsr    Editor_Animate
  719. .exit    rts
  720.  
  721. *
  722. * gadget_play
  723. *
  724. *
  725.  
  726. gadget_play
  727.  
  728. * Store Current Grid Field in a temporary File
  729.     lea    temp_file_name,a2
  730.     bsr    Save_Field
  731.  
  732. * Let The User Select A Game Field
  733.  
  734. .load    lea    play_tags,a0
  735.     move.l    BD_window,ti_Data(a0)
  736.     move.l    play_file_requester,a1
  737.     lea    play_filename,a2
  738.     lea    play_title,a3
  739.     CALLREQT rtFileRequestA
  740.     move.l    d0,d0
  741.     beq    .no_file
  742.  
  743.     lea    play_filename,a0
  744.     lea    completename,a1
  745.     move.l    play_file_requester,a2
  746.     bsr    Make_File_Name
  747.     lea    completename,a2
  748.     bsr    Load_Field
  749.     move.l    d0,d0
  750.     bne    .load
  751.  
  752. * Remember Our screen view
  753.     move.l    _GfxBase,a0
  754.     move.l    $22(a0),edit_view
  755.  
  756.     move.l    time_data,d0
  757.     move.l    target_data,d1
  758.     move.w    ted_x,d2
  759.     move.w    ted_y,d3
  760.     jsr    Play
  761.  
  762. * Load Old Grid Field
  763.     lea    temp_file_name,a2
  764.     bsr    Load_Field
  765.  
  766. * Restore Screen
  767.     bsr    Display_Gadgets_Images
  768.  
  769. * Restore Editor Settings
  770.     move.l    #2*grid_sizeof,screen_x
  771.     move.l    #2*grid_sizeof*GRIDF_WIDTH,screen_y
  772.  
  773.     move.l    grid_field,a2
  774.     add.l    screen_x,a2
  775.     add.l    screen_y,a2
  776.     move.l    bitmap1,a3
  777.     move.l    bitmapg,a4
  778.     add.l    #bm_Planes,a3
  779.     add.l    #bm_Planes,a4
  780.     jsr    Editor_Animate
  781.  
  782. * Display Screen
  783.     move.l    edit_view,a1        ; Load our original view.
  784.     GRAFCALL LoadView
  785.  
  786.     lea    score_tags,a0
  787.     move.l    BD_window,ti_Data(a0)
  788.     lea    score_bodyfmt,a1
  789.     lea    score_gadfmt,a2
  790.     sub.l    a3,a3
  791.     lea    score_args,a4
  792.     move.w    integer_score,(a4)
  793.     move.w    integer_target,2(a4)
  794.     move.w    integer_time,4(a4)
  795.     CALLREQT rtEZRequestA
  796.  
  797. .no_file
  798. .exit    rts
  799.  
  800.  
  801. *
  802. * gadget_test
  803. *
  804. *
  805.  
  806. gadget_test
  807.     move.l    _GfxBase,a0
  808.     move.l    $22(a0),edit_view
  809.  
  810. * Save Current Game Field to a temporary file.
  811.     lea    temp_file_name,a2
  812.     bsr    Save_Field
  813.  
  814.     move.l    time_data,d0
  815.     move.l    target_data,d1
  816.     move.w    ted_x,d2
  817.     move.w    ted_y,d3
  818.     jsr    Play
  819.  
  820. * Restore Game Field.
  821.     lea    temp_file_name,a2
  822.     bsr    Load_Field
  823.  
  824.     bsr    Display_Gadgets_Images
  825.  
  826.     move.l    #2*grid_sizeof,screen_x
  827.     move.l    #2*grid_sizeof*GRIDF_WIDTH,screen_y
  828.  
  829.     move.l    grid_field,a2
  830.     add.l    screen_x,a2
  831.     add.l    screen_y,a2
  832.     move.l    bitmap1,a3
  833.     move.l    bitmapg,a4
  834.     add.l    #bm_Planes,a3
  835.     add.l    #bm_Planes,a4
  836.     jsr    Editor_Animate
  837.  
  838.     move.l    edit_view,a1        ; Load our original view.
  839.     GRAFCALL LoadView
  840.  
  841.     rts
  842.  
  843. *
  844. *
  845. * gadget_load
  846. *
  847. *
  848.  
  849. gadget_load
  850.     move.w    flag_work_dirty,d0
  851.     beq    .load
  852.     lea    sw_tags,a0
  853.     move.l    BD_window,ti_Data(a0)
  854.     lea    sw_bodyfmt,a1
  855.     lea    sw_gadfmt,a2
  856.     sub.l    a3,a3
  857.     sub.l    a4,a4
  858.     CALLREQT rtEZRequestA
  859.     move.l    d0,d7
  860.     beq    .load
  861.     bsr    gadget_save
  862.  
  863. .load    lea    load_tags,a0
  864.     move.l    BD_window,ti_Data(a0)
  865.     move.l    loadsave_file_requester,a1
  866.     lea    filename,a2
  867.     lea    load_title,a3
  868.     CALLREQT rtFileRequestA
  869.     move.l    d0,d0
  870.     beq    .no_file
  871.  
  872.     move.w    #FALSE,flag_work_dirty
  873.  
  874.     lea    filename,a0
  875.     lea    completename,a1
  876.     move.l    loadsave_file_requester,a2
  877.     bsr    Make_File_Name
  878.     lea    completename,a2
  879.     bsr    Load_Field
  880.     move.l    d0,d0
  881.     bne    .load
  882.  
  883. * Show Grid Field
  884.     move.l    #2*grid_sizeof,screen_x
  885.     move.l    #2*grid_sizeof*GRIDF_WIDTH,screen_y
  886.  
  887.     move.l    grid_field,a2
  888.     add.l    screen_x,a2
  889.     add.l    screen_y,a2
  890.     move.l    bitmap1,a3
  891.     move.l    bitmapg,a4
  892.     add.l    #bm_Planes,a3
  893.     add.l    #bm_Planes,a4
  894.     jsr    Editor_Animate
  895.  
  896. .no_file
  897. .exit    rts
  898.  
  899. *
  900. *
  901. * gadget_save
  902. *
  903. *
  904.  
  905. gadget_save
  906.     lea    save_tags,a0
  907.     move.l    BD_window,ti_Data(a0)
  908.     move.l    loadsave_file_requester,a1
  909.     lea    filename,a2
  910.     lea    save_title,a3
  911.     CALLREQT rtFileRequestA
  912.     move.l    d0,d0
  913.     beq    .no_file
  914.  
  915.     move.w    #FALSE,flag_work_dirty
  916.  
  917.     lea    filename,a0
  918.     lea    completename,a1
  919.     move.l    loadsave_file_requester,a2
  920.     bsr    Make_File_Name
  921.     lea    completename,a2
  922.     bsr    Save_Field
  923.  
  924. .no_file
  925. .exit    rts
  926.  
  927. *
  928. *
  929. * gadget_clr
  930. *
  931. *
  932.  
  933. gadget_clr
  934.     move.w    flag_work_dirty,d0
  935.     beq    .clear
  936.     lea    clr_tags,a0
  937.     move.l    BD_window,ti_Data(a0)
  938.     lea    clr_bodyfmt,a1
  939.     lea    clr_gadfmt,a2
  940.     sub.l    a3,a3
  941.     sub.l    a4,a4
  942.     CALLREQT rtEZRequestA
  943.     move.l    d0,d7
  944.     beq    .exit
  945.  
  946. * Restore Editor Settings
  947. .clear    move.w    #FALSE,flag_work_dirty
  948.  
  949.     lea    filename,a0
  950.     move.b    #0,(a0)
  951.  
  952. * Clear Grid Field
  953.     move.l    grid_field,a0
  954.     lea    test_field,a1
  955.     bsr    Init_Grid_Field
  956.  
  957. * Reset Cursor
  958.     move.l    #2*grid_sizeof,screen_x
  959.     move.l    #2*grid_sizeof*GRIDF_WIDTH,screen_y
  960.     move.w    #0,ted_x
  961.     move.w    #0,ted_y
  962.  
  963. * Show Grid Field
  964.     move.l    grid_field,a2
  965.     add.l    screen_x,a2
  966.     add.l    screen_y,a2
  967.     move.l    bitmap1,a3
  968.     move.l    bitmapg,a4
  969.     add.l    #bm_Planes,a3
  970.     add.l    #bm_Planes,a4
  971.     jsr    Editor_Animate
  972. .exit    rts
  973.  
  974. *
  975. * gadget_quit
  976. *
  977. *
  978.  
  979. gadget_quit
  980.     move.w    flag_work_dirty,d0
  981.     beq    .quit
  982.     lea    sw_tags,a0
  983.     move.l    BD_window,ti_Data(a0)
  984.     lea    sw_bodyfmt,a1
  985.     lea    sw_gadfmt,a2
  986.     sub.l    a3,a3
  987.     sub.l    a4,a4
  988.     CALLREQT rtEZRequestA
  989.     move.l    d0,d7
  990.     beq    .quit
  991.     bsr    gadget_save
  992. .quit    move.l    editor_break,a7
  993. .exit    rts
  994.  
  995.  
  996. *
  997. * gadget_time
  998. *
  999. *
  1000.  
  1001. gadget_time
  1002.     lea    time_tags,a0
  1003.     move.l    BD_window,ti_Data(a0)
  1004.     lea    time_data,a1
  1005.     lea    time_title,a2
  1006.     sub.l    a3,a3
  1007.     CALLREQT rtGetLongA
  1008.     rts
  1009.  
  1010. *
  1011. * gadget_target
  1012. *
  1013. *
  1014.  
  1015. gadget_target
  1016.     lea    target_tags,a0
  1017.     move.l    BD_window,ti_Data(a0)
  1018.     lea    target_data,a1
  1019.     lea    target_title,a2
  1020.     sub.l    a3,a3
  1021.     CALLREQT rtGetLongA
  1022.     rts
  1023.  
  1024. *
  1025. * gadget_help
  1026. *
  1027. *
  1028.  
  1029. gadget_help
  1030. *    lea    help_tags,a0
  1031. *    move.l    BD_window,ti_Data(a0)
  1032.     sub.l    a0,a0
  1033.     lea    help_bodyfmt,a1
  1034.     lea    help_gadfmt,a2
  1035.     sub.l    a3,a3
  1036.     sub.l    a4,a4
  1037.     CALLREQT rtEZRequestA
  1038.     rts
  1039.  
  1040.  
  1041. gadget_dummy
  1042.     rts
  1043.  
  1044. ***
  1045.  
  1046. *
  1047. * Panic - Inform User That Something Went Wrong
  1048. *
  1049. *
  1050.  
  1051. Panic ; ()
  1052.  
  1053.     lea    panic_tags,a0
  1054.     move.l    BD_window,ti_Data(a0)
  1055.     lea    panic_bodyfmt,a1
  1056.     lea    panic_gadfmt,a2
  1057.     sub.l    a3,a3
  1058.     sub.l    a4,a4
  1059.     CALLREQT rtEZRequestA
  1060.     rts
  1061.  
  1062.  
  1063. *
  1064. * Panic2 - Inform User That Something Went Wrong
  1065. *
  1066. *
  1067.  
  1068. Panic2 ; ()
  1069.  
  1070.     lea    panic2_tags,a0
  1071.     move.l    BD_window,ti_Data(a0)
  1072.     lea    panic2_bodyfmt,a1
  1073.     lea    panic2_gadfmt,a2
  1074.     sub.l    a3,a3
  1075.     sub.l    a4,a4
  1076.     CALLREQT rtEZRequestA
  1077.     rts
  1078.  
  1079.  
  1080. *
  1081. * Make_File_Name - Join Filename and Directory name
  1082. *
  1083. *
  1084.  
  1085. Make_File_Name ; (FileName,CompleteName,File_Requester),a0,a1,a2
  1086.  
  1087.     move.l    rtfi_Dir(a2),a2
  1088. .loop1
  1089.     move.b    (a2)+,d0
  1090.     beq.s    .ex1
  1091.     move.b    d0,(a1)+
  1092.     bra.s    .loop1
  1093. .ex1    cmp.b    #':',-1(a1)
  1094.     beq.s    .ok
  1095.     cmp.b    #'/',-1(a1)
  1096.     beq.s    .ok
  1097.     move.b    #'/',(a1)+
  1098. .ok    move.b    (a0)+,d0
  1099.     move.b    d0,(a1)+
  1100.     bne.s    .ok
  1101.  
  1102.     cmp.b    #'d',-2(a1)
  1103.     bne.s    .add_bd
  1104.     cmp.b    #'b',-3(a1)
  1105.     bne.s    .add_bd
  1106.     cmp.b    #'.',-4(a1)
  1107.     beq.s    .exit
  1108. .add_bd    subq.l    #1,a1
  1109.     move.b    #'.',(a1)+
  1110.     move.b    #'b',(a1)+
  1111.     move.b    #'d',(a1)+
  1112.     move.b    #0,(a1)
  1113. .exit    rts
  1114.  
  1115.  
  1116. *
  1117. * Save_Field
  1118. *
  1119. *
  1120. *
  1121.  
  1122. Save_Field ; (Filename),a2
  1123.  
  1124.     move.l    #GAME_FILE_SIZE,d0
  1125.     move.l    #MEMF_PUBLIC|MEMF_CLEAR,d1
  1126.     EXECCALL AllocMem
  1127.     move.l    d0,compact_field
  1128.     bne.s    .ok0
  1129.     bsr    Panic2
  1130.     bra    .exit
  1131.  
  1132. .ok0    move.l    d0,a0
  1133.     move.l    time_data,(a0)+
  1134.     move.l    target_data,(a0)+
  1135.     move.w    ted_x,(a0)+
  1136.     move.w    ted_y,(a0)+
  1137.     move.l    grid_field,a1
  1138.     moveq    #GRIDF_HEIGHT-1,d0
  1139. .loop1    moveq    #GRIDF_WIDTH-1,d1
  1140. .loop2    move.w    grid_type(a1),d2
  1141.     move.b    d2,(a0)+
  1142.     addq.l    #grid_sizeof,a1
  1143.     dbra    d1,.loop2
  1144.     dbra    d0,.loop1
  1145.  
  1146.     move.l    a2,d1
  1147.     move.l    #MODE_NEWFILE,d2
  1148.     DOSCALL    Open
  1149.     move.l    d0,filehandle
  1150.     bne    .ok1
  1151.     bsr    Panic
  1152.     bra    .cleanup1
  1153.  
  1154. .ok1    move.l    filehandle,d1
  1155.     move.l    compact_field,d2
  1156.     move.l    #GAME_FILE_SIZE,d3
  1157.     DOSCALL    Write
  1158.     cmp.l    #-1,d0
  1159.     bne.s    .cleanup2
  1160.     bsr    Panic
  1161. .cleanup2
  1162.     move.l    compact_field,a1
  1163.     move.l    #GAME_FILE_SIZE,d0
  1164.     EXECCALL FreeMem
  1165. .cleanup1
  1166.     move.l    filehandle,d1
  1167.     DOSCALL Close
  1168. .exit    rts
  1169.  
  1170.  
  1171. *
  1172. * Load_Field
  1173. *
  1174. *
  1175. *
  1176.  
  1177. Load_Field ; (Filename),a2  -> (Error),d0
  1178.  
  1179.     moveq    #0,d7
  1180.     move.l    #GAME_FILE_SIZE,d0
  1181.     move.l    #MEMF_PUBLIC|MEMF_CLEAR,d1
  1182.     EXECCALL AllocMem
  1183.     move.l    d0,compact_field
  1184.     bne    .ok0
  1185.     bsr    Panic2
  1186.     moveq    #-1,d7
  1187.     bra    .exit
  1188. .ok0
  1189.     move.l    a2,d1
  1190.     move.l    #MODE_OLDFILE,d2
  1191.     DOSCALL    Open
  1192.     move.l    d0,filehandle
  1193.     bne.s    .ok1
  1194.     moveq    #-1,d7
  1195.     bsr    Panic
  1196.     bra    .cleanup1
  1197.  
  1198. .ok1    move.l    filehandle,d1
  1199.     move.l    compact_field,d2
  1200.     move.l    #GAME_FILE_SIZE,d3
  1201.     DOSCALL    Read
  1202.     cmp.l    #-1,d0
  1203.     bne.s    .ok2
  1204.     moveq    #-1,d7
  1205.     bsr    Panic
  1206.     bra    .cleanup2
  1207.  
  1208. .ok2
  1209. * Convert File into Grid Field and read game time and target and ted coords
  1210.     move.l    grid_field,a0
  1211.     move.l    compact_field,a1
  1212.     move.l    (a1)+,time_data
  1213.     move.l    (a1)+,target_data
  1214.     move.w    (a1)+,ted_x
  1215.     move.w    (a1)+,ted_y
  1216.     bsr    Init_Grid_Field
  1217.  
  1218. .cleanup2
  1219.     move.l    compact_field,a1
  1220.     move.l    #GAME_FILE_SIZE,d0
  1221.     EXECCALL FreeMem
  1222. .cleanup1
  1223.     move.l    filehandle,d1
  1224.     DOSCALL Close
  1225. .exit    move.l    d7,d0
  1226.     rts
  1227.  
  1228. *
  1229. * proc_mouse - Draw grid object at current mouse position
  1230. *
  1231. *
  1232. *
  1233.  
  1234. proc_mouse ; ()
  1235.  
  1236.  
  1237. * Is it a Legal Position.
  1238.     moveq    #0,d0
  1239.     moveq    #0,d1
  1240.     move.w    bd_ms_mousex,d0
  1241.     move.w    bd_ms_mousey,d1
  1242.     lsr.l    #4,d0
  1243.     sub.l    #32+16,d1
  1244.     bmi    .exit
  1245.     lsr.l    #4,d1
  1246.     mulu    #grid_sizeof,d0
  1247.     mulu    #grid_sizeof*GRIDF_WIDTH,d1
  1248.     add.l    screen_x,d0
  1249. * Make sure the position is not on a border element. 
  1250.     cmp.l    #3*grid_sizeof,d0
  1251.     blo    .exit
  1252.     cmp.l    #(GRIDF_WIDTH-3)*grid_sizeof,d0
  1253.     bhs    .exit
  1254.     add.l    d1,d0
  1255.     add.l    screen_y,d0
  1256.     cmp.l    #3*grid_sizeof*GRIDF_WIDTH,d0
  1257.     bls    .exit
  1258.     cmp.l    #(GRIDF_HEIGHT-3)*grid_sizeof*GRIDF_WIDTH,d0
  1259.     bhs    .exit
  1260.  
  1261.     move.w    #TRUE,flag_work_dirty
  1262.  
  1263. * Is It A Ted ?
  1264.     cmp.w    #G_TED,CObject_type
  1265.     bne    .noted
  1266.  
  1267. * Remove Old Ted
  1268.     moveq    #0,d0
  1269.     moveq    #0,d1
  1270.     move.w    ted_x,d0
  1271.     move.w    ted_y,d1
  1272.     addq.w    #3,d0
  1273.     addq.w    #3,d1
  1274.     mulu    #grid_sizeof,d0
  1275.     mulu    #grid_sizeof*GRIDF_WIDTH,d1
  1276.     add.l    d0,d1
  1277.     move.l    grid_field,a0
  1278.     add.l    d1,a0
  1279.     move.w    #DRAW_DIRT,grid_draw(a0)
  1280.     move.w    #G_DIRT,grid_type(a0)
  1281.     move.w    #TRANS_NONE,grid_trans(a0)
  1282.     move.b    #2,grid_dirty(a0)
  1283.     move.b    #0,grid_data(a0)
  1284.  
  1285. * Redraw Screen
  1286.     move.l    grid_field,a2
  1287.     add.l    screen_x,a2
  1288.     add.l    screen_y,a2
  1289.     move.l    bitmap1,a3
  1290.     move.l    bitmapg,a4
  1291.     add.l    #bm_Planes,a3
  1292.     add.l    #bm_Planes,a4
  1293.     jsr    Editor_Animate
  1294.  
  1295. * Calc Pos New Ted
  1296.     moveq    #0,d0
  1297.     moveq    #0,d1
  1298.     move.w    bd_ms_mousex,d0
  1299.     move.w    bd_ms_mousey,d1
  1300.     lsr.l    #4,d0
  1301.     sub.l    #32+16,d1
  1302.     lsr.l    #4,d1
  1303.     subq    #1,d0
  1304.     subq    #1,d1
  1305.     move.l    screen_x,d2
  1306.     divu    #grid_sizeof,d2
  1307.     subq.w    #2,d2
  1308.     add.w    d2,d0
  1309.     move.l    screen_y,d2
  1310.     divu    #grid_sizeof*GRIDF_WIDTH,d2
  1311.     subq.w    #2,d2
  1312.     add.w    d2,d1
  1313.     move.w    d0,ted_x
  1314.     move.w    d1,ted_y
  1315.  
  1316. * Put New Object In Grid Field
  1317. * Calc Position
  1318. .noted    moveq    #0,d0
  1319.     moveq    #0,d1
  1320.     move.w    bd_ms_mousex,d0
  1321.     move.w    bd_ms_mousey,d1
  1322.     lsr.l    #4,d0
  1323.     sub.l    #32+16,d1
  1324.     lsr.l    #4,d1
  1325.     mulu    #grid_sizeof,d0
  1326.     mulu    #grid_sizeof*GRIDF_WIDTH,d1
  1327.     add.l    screen_x,d0
  1328.     add.l    d1,d0
  1329.     add.l    screen_y,d0
  1330.  
  1331. * Put it in the grid_field
  1332.     move.l    grid_field,a0
  1333. * Is the User Trying to Kill Ted ?
  1334.     cmp.w    #G_TED,grid_type(a0,d0)
  1335.     bne.s    .nopp
  1336.     cmp.w    #G_TED,CObject_type
  1337.     bne.s    .exit
  1338. .nopp    move.w    CObject_draw,grid_draw(a0,d0)
  1339.     move.w    CObject_type,grid_type(a0,d0)
  1340.     move.w    CObject_trans,grid_trans(a0,d0)
  1341.     move.b    #2,grid_dirty(a0,d0)
  1342.     move.b    #0,grid_data(a0,d0)
  1343.  
  1344. * Display New Object
  1345.     moveq    #0,d0
  1346.     moveq    #0,d1
  1347.     move.w    bd_ms_mousex,d0
  1348.     move.w    bd_ms_mousey,d1
  1349.     lsr.l    #4,d0            x=x/16
  1350.     lsl.l    #1,d0            x=x*2
  1351.     and.w    #$FFF0,d1        y=(y div 16)*16
  1352.     mulu    #BM_width,d1
  1353.     add.l    d1,d0
  1354.     move.l    d0,d2
  1355.  
  1356.     moveq    #0,d1
  1357.     move.w    CObject_draw,d1
  1358.  
  1359.     move.l    bitmap1,a3
  1360.     move.l    bitmapg,a4
  1361.     add.l    #bm_Planes,a3
  1362.     add.l    #bm_Planes,a4
  1363.     bsr    Editor_Draw_One_Object
  1364.  
  1365. .exit    rts
  1366.  
  1367.  
  1368. *
  1369. * Init_Grid_Field - Convert a compact field to a grid field.
  1370. *
  1371. *   A0 - a pointer to the grid field
  1372. *   A1 - a pointer to a compact field
  1373. *
  1374.  
  1375. Init_Grid_Field ; (grid_field,compact_field),A0, A1
  1376.  
  1377.     move.w    #NUMBER_OF_GRIDS-1,d0
  1378. .ll1
  1379.     moveq    #0,d1
  1380.     move.b    (a1)+,d1
  1381.     cmp.b    #G_BORDER,d1
  1382.     bne.s    .pos2
  1383.     move.w    #DRAW_BORDER,(a0)+        drawing procedure
  1384.     move.w    #TRANS_NONE,(a0)+        transition procedure
  1385.     move.w    #G_BORDER,(a0)+            type
  1386.     move.b    #2,(a0)+            dirty code
  1387.     move.b    #0,(a0)+            data
  1388.     bra    .next
  1389. .pos2    cmp.b    #G_EMPTY,d1
  1390.     bne.s    .pos3
  1391.     move.w    #DRAW_EMPTY,(a0)+
  1392.     move.w    #TRANS_NONE,(a0)+
  1393.     move.w    d1,(a0)+
  1394.     move.b    #2,(a0)+
  1395.     move.b    #EMPTY_REAL_EMPTY,(a0)+
  1396.     bra    .next
  1397. .pos3    cmp.b    #G_DIRT,d1
  1398.     bne.s    .pos4
  1399.     move.w    #DRAW_DIRT,(a0)+
  1400.     move.w    #TRANS_NONE,(a0)+
  1401.     move.w    d1,(a0)+
  1402.     move.b    #2,(a0)+
  1403.     move.b    #0,(a0)+
  1404.     bra    .next
  1405. .pos4    cmp.b    #G_ROCK,d1
  1406.     bne.s    .pos5
  1407.     move.w    #DRAW_ROCK,(a0)+
  1408.     move.w    #TRANS_NONE,(a0)+
  1409.     move.w    d1,(a0)+
  1410.     move.b    #2,(a0)+
  1411.     move.b    #ROCK_STEADY,(a0)+
  1412.     bra    .next
  1413. .pos5    cmp.b    #G_DIAMOND,d1
  1414.     bne.s    .pos6
  1415.     move.w    #DRAW_DIAMOND,(a0)+
  1416.     move.w    #TRANS_NONE,(a0)+
  1417.     move.w    d1,(a0)+
  1418.     move.b    #2,(a0)+
  1419.     move.b    #0,(a0)+
  1420.     bra    .next
  1421. .pos6    cmp.b    #G_BUTTERFLY,d1
  1422.     bne.s    .pos7
  1423.     move.w    #DRAW_BUTTERFLY,(a0)+
  1424.     move.w    #TRANS_NONE,(a0)+
  1425.     move.w    d1,(a0)+
  1426.     move.b    #2,(a0)+
  1427.     move.b    #MOVING_UP,(a0)+
  1428.     bra    .next
  1429. .pos7    cmp.b    #G_BRICK,d1
  1430.     bne.s    .pos8
  1431.     move.w    #DRAW_BRICK,(a0)+
  1432.     move.w    #TRANS_NONE,(a0)+
  1433.     move.w    d1,(a0)+
  1434.     move.b    #2,(a0)+
  1435.     move.b    #0,(a0)+
  1436.     bra    .next
  1437. .pos8    cmp.b    #G_FUNGIS,d1
  1438.     bne.s    .pos9
  1439.     move.w    #DRAW_FUNGIS,(a0)+
  1440.     move.w    #TRANS_NONE,(a0)+
  1441.     move.w    d1,(a0)+
  1442.     move.b    #2,(a0)+
  1443.     move.b    #0,(a0)+
  1444.     bra    .next
  1445. .pos9    cmp.b    #G_MOVER,d1
  1446.     bne.s    .pos10
  1447.     move.w    #DRAW_MOVER,(a0)+
  1448.     move.w    #TRANS_NONE,(a0)+
  1449.     move.w    d1,(a0)+
  1450.     move.b    #2,(a0)+
  1451.     move.b    #MOVING_UP,(a0)+
  1452.     bra    .next
  1453. .pos10    cmp.b    #G_TED,d1
  1454.     bne.s    .pos11
  1455.     move.w    #DRAW_TED,(a0)+
  1456.     move.w    #TRANS_NONE,(a0)+
  1457.     move.w    d1,(a0)+
  1458.     move.b    #2,(a0)+
  1459.     move.b    #MOVING_UP,(a0)+
  1460.     bra    .next
  1461. .pos11    cmp.b    #G_EXIT,d1
  1462.     bne.s    .pos12
  1463.     move.w    #DRAW_EXIT,(a0)+
  1464.     move.w    #TRANS_NONE,(a0)+
  1465.     move.w    d1,(a0)+
  1466.     move.b    #2,(a0)+
  1467.     move.b    #0,(a0)+
  1468.     bra    .next
  1469. .pos12    nop
  1470. .next    dbra    d0,.ll1
  1471.     rts
  1472.  
  1473.  
  1474. **********************************************************
  1475.  
  1476. editor_break    dc.l    0
  1477. edit_view    dc.l    0
  1478. screen_x    dc.l    0
  1479. screen_y    dc.l    0
  1480. ted_x        dc.w    0
  1481. ted_y        dc.w    0
  1482.  
  1483.  
  1484. compact_field    dc.l    0
  1485. filehandle    dc.l    0
  1486.  
  1487. * Current Object to Draw in Grid
  1488. CObject_trans    dc.w    0
  1489. CObject_draw    dc.w    0
  1490. CObject_type    dc.w    0
  1491.         even
  1492.  
  1493. * Message Buffer
  1494. bd_ms_class    dc.l    0
  1495. bd_ms_code    dc.w    0
  1496. bd_ms_iaddress    dc.l    0
  1497. bd_ms_mousex    dc.w    0
  1498. bd_ms_mousey    dc.w    0
  1499.  
  1500. BD_screen    dc.l    0
  1501. BD_window    dc.l    0
  1502.  
  1503. BD_newscreen
  1504.     dc.w    0,0                leftedge,topedge
  1505.     dc.w    BD_SCREEN_x,BD_SCREEN_y        width,height
  1506.     dc.w    BD_SCREEN_d            depth
  1507.     dc.b    6,0                detailpeb,blockpen
  1508.     dc.w    0                display mode
  1509.     dc.w    CUSTOMSCREEN|CUSTOMBITMAP    type
  1510.     dc.l    0                font
  1511.     dc.l    bdname                name
  1512.     dc.l    0                gadgets
  1513.     dc.l    0                custom bitmap
  1514.  
  1515.     even
  1516. bdname    dc.b    'Boulderdash Editor v1.0',0
  1517.     even
  1518.  
  1519. BD_newwindow
  1520.     dc.w    0,0                    leftedge,topedge
  1521.     dc.w    BD_SCREEN_x,BD_SCREEN_y            width,height
  1522.     dc.b    0,1                    detailpeb,blockpen
  1523.     dc.l    GADGETUP|MOUSEBUTTONS|RAWKEY|MENUPICK    IDCMFlags
  1524.     dc.l    SMART_REFRESH|BACKDROP|BORDERLESS    Flags
  1525.     dc.l    BD_Gadgets                Gadgets
  1526.     dc.l    0                    CheckMark
  1527.     dc.l    0                    Title
  1528.     dc.l    0                    Screen
  1529.     dc.l    0                    BitMap
  1530.     dc.w    BD_SCREEN_x,BD_SCREEN_y            min
  1531.     dc.w    BD_SCREEN_x,BD_SCREEN_y            max
  1532.     dc.w    CUSTOMSCREEN                Type
  1533.  
  1534.     even
  1535.  
  1536. Make_Gadget    macro
  1537.     dc.l    \1
  1538.     dc.w    \2,\3+GADGET_OFFSET,\4,\5
  1539.     dc.w    GADGHCOMP        flags
  1540.     dc.w    RELVERIFY        activation
  1541.     dc.w    BOOLGADGET        type
  1542.     dc.l    0            gadget render
  1543.     dc.l    0            select render
  1544.     dc.l    0            text
  1545.     dc.l    0            mutualexclude
  1546.     dc.l    0            spec info
  1547.     dc.w    \6            id
  1548.     dc.l    0
  1549.         endm
  1550.  
  1551.  
  1552. BD_Gadgets
  1553.     Make_Gadget    gg2,0,0,16,16,GADGET_DIAMOND
  1554. gg2    Make_Gadget    gg3,16,0,16,16,GADGET_TED
  1555. gg3    Make_Gadget    gg4,32,0,16,16,GADGET_BRICK
  1556. gg4    Make_Gadget    gg5,48,0,16,16,GADGET_BORDER
  1557. gg5    Make_Gadget    gg6,64,0,16,16,GADGET_MOVER
  1558. gg6    Make_Gadget    gg7,0,16,16,16,GADGET_ROCK
  1559. gg7    Make_Gadget    gg8,16,16,16,16,GADGET_DIRT
  1560. gg8    Make_Gadget    gg9,32,16,16,16,GADGET_EMPTY
  1561. gg9    Make_Gadget    gg10,48,16,16,16,GADGET_BUTTERFLY
  1562. gg10    Make_Gadget    gg11,64,16,16,16,GADGET_FUNGIS
  1563.  
  1564. gg11    Make_Gadget    gg12,128,8,16,16,GADGET_FAST_LEFT
  1565. gg12    Make_Gadget    gg13,160,8,16,16,GADGET_FAST_RIGHT
  1566. gg13    Make_Gadget    gg14,144,0,16,16,GADGET_FAST_UP
  1567. gg14    Make_Gadget    gg15,144,16,16,16,GADGET_FAST_DOWN
  1568.  
  1569. gg15    Make_Gadget    gg16,176,8,16,16,GADGET_LEFT
  1570. gg16    Make_Gadget    gg17,208,8,16,16,GADGET_RIGHT
  1571. gg17    Make_Gadget    gg18,192,0,16,16,GADGET_UP
  1572. gg18    Make_Gadget    gg19,192,16,16,16,GADGET_DOWN
  1573.  
  1574. gg19    Make_Gadget    gg20,240,0,16,16,GADGET_PLAY
  1575. gg20    Make_Gadget    gg21,240,16,16,16,GADGET_TEST
  1576. gg21    Make_Gadget    gg22,272,0,16,16,GADGET_SAVE
  1577. gg22    Make_Gadget    gg23,272,16,16,16,GADGET_LOAD
  1578. gg23    Make_Gadget    gg24,304,0,16,16,GADGET_QUIT
  1579. gg24    Make_Gadget    gg25,304,16,16,16,GADGET_CLR
  1580. gg25    Make_Gadget    gg26,224,0,16,16,GADGET_TIME
  1581. gg26    Make_Gadget    gg27,224,16,16,16,GADGET_TARGET
  1582. gg27    Make_Gadget    gg28,256,0,16,16,GADGET_HELP
  1583. gg28    Make_Gadget    0,80,0,16,16,GADGET_EXIT
  1584.  
  1585.  
  1586. Make_Menu    macro
  1587.     dc.l    \1            NextMenu
  1588.     dc.w    \2,0,\3,\4
  1589.     dc.w    MENUENABLED        flags
  1590.     dc.l    \@            name
  1591.     dc.l    \6            first item
  1592.     dc.w    0,0,0,0
  1593. \@    dc.b    \5,0
  1594.     even
  1595.         endm
  1596.  
  1597. Make_Item    macro
  1598.     dc.l    \1            NextItem
  1599.     dc.w    \2,\3,\6,10
  1600.     dc.w    ITEMTEXT|HIGHCOMP|ITEMENABLED|COMMSEQ        flags
  1601.     dc.l    0            Mut Excl
  1602.     dc.l    \@            ItemFill
  1603.     dc.l    0            SelectFill
  1604.     dc.b    \5            Command
  1605.     dc.b    0
  1606.     dc.l    0            SubItem
  1607.     dc.w    0            Next Select
  1608.  
  1609. \@    dc.b    0            FrontPen
  1610.     dc.b    1            BackPen
  1611.     dc.b    RP_JAM2            Draw Mode
  1612.     dc.b    0
  1613.     dc.w    0,0            Left_Edge,Top_Edge
  1614.     dc.l    0            Font
  1615.     dc.l    \@T            Text
  1616.     dc.l    0            NextText
  1617. \@T    dc.b    \4,0
  1618.     even
  1619.         endm
  1620.  
  1621. Def_Menu    macro
  1622. MENU\1        equ    IDMenu
  1623. IDMenu        set    IDMenu+1
  1624. IDMenuItem    set    0
  1625.         endm
  1626.  
  1627. Def_Item    macro
  1628. ITEM\1        equ    IDMenuItem
  1629. IDMenuItem    set    IDMenuItem+1
  1630.         endm
  1631.  
  1632.  
  1633. IDMenu        set    0
  1634.  
  1635.     Def_Menu    Project
  1636.     Def_Item    Clear
  1637.     Def_Item    Open
  1638.     Def_Item    Save
  1639.     Def_Item    Quit
  1640.     Def_Item    Help
  1641.     Def_Menu    Game
  1642.     Def_Item    Play
  1643.     Def_Item    Test
  1644.     Def_Item    Time
  1645.     Def_Item    Target
  1646.  
  1647. menu1    Make_Menu    menu2,5,60,40,"Project",item11
  1648. item11    Make_Item    item12,5,4,"New",'N',64
  1649. item12    Make_Item    item13,5,14,"Open",'O',64
  1650. item13    Make_Item    item14,5,24,"Save",'W',64
  1651. item14    Make_Item    item15,5,34,"Quit",'Q',64
  1652. item15    Make_Item    0,5,50,"Help",'H',64
  1653. menu2    Make_Menu    0,80,60,40,"GAME",item21
  1654. item21    Make_Item    item22,5,4,"Play",'P',80
  1655. item22    Make_Item    item23,5,14,"Test",'T',80
  1656. item23    Make_Item    item24,5,24,"Time",'I',80
  1657. item24    Make_Item    0,5,34,"Target",'A',80
  1658.  
  1659.         even
  1660.  
  1661. flag_work_dirty        dc.w    0
  1662.  
  1663. play_file_requester    dc.l    0
  1664. loadsave_file_requester    dc.l    0
  1665.  
  1666. * Save Game Field Requester
  1667. save_title    dc.b    "SAVE GAME FIELD",0
  1668.         even
  1669. save_tags    dc.l    RT_Window
  1670.         dc.l    0
  1671.         dc.l    RTFI_Flags
  1672.         dc.l    FREQF_SAVE
  1673.         dc.l    RTFI_Flags
  1674.         dc.l    FREQF_PATGAD
  1675.         dc.l    RTFI_OkText
  1676.         dc.l    save_ok
  1677.         dc.l    TAG_END
  1678.         dc.l    0
  1679. save_ok        dc.b    'SAVE',0
  1680.         even
  1681.  
  1682. * Load Game Field Requester
  1683. load_title    dc.b    "LOAD GAME FIELD",0
  1684.         even
  1685. load_tags    dc.l    RT_Window
  1686.         dc.l    0
  1687.         dc.l    RTFI_Flags
  1688.         dc.l    FREQF_PATGAD
  1689.         dc.l    RTFI_OkText
  1690.         dc.l    load_ok
  1691.         dc.l    TAG_END
  1692.         dc.l    0
  1693. load_ok        dc.b    'LOAD',0
  1694.         even
  1695.  
  1696. * Play Game Requester
  1697. play_title    dc.b    "SELECT GAME FIELD",0
  1698.         even
  1699. play_tags    dc.l    RT_Window
  1700.         dc.l    0
  1701.         dc.l    RTFI_Flags
  1702.         dc.l    FREQF_PATGAD
  1703.         dc.l    RTFI_OkText
  1704.         dc.l    play_ok
  1705.         dc.l    TAG_END
  1706.         dc.l    0
  1707. play_ok        dc.b    'PLAY',0
  1708.         even
  1709.  
  1710. * Panic Requester
  1711. panic_bodyfmt    dc.b    "Can't Access File !",0
  1712. panic_gadfmt    dc.b    "That's too bad",0
  1713.         even
  1714. panic_tags    dc.l    RT_Window
  1715.         dc.l    0
  1716.         dc.l    TAG_END
  1717.         dc.l    0
  1718. panic2_bodyfmt    dc.b    "! Out of Memory !",0
  1719. panic2_gadfmt    dc.b    "That's too bad",0
  1720.         even
  1721. panic2_tags    dc.l    RT_Window
  1722.         dc.l    0
  1723.         dc.l    TAG_END
  1724.         dc.l    0
  1725.  
  1726. * Save Work  Requester
  1727. sw_bodyfmt    dc.b    "You've Made Some Changes",10
  1728.         dc.b    "to this Game Field.",10
  1729.         dc.b    "Want to Save Them ?",0
  1730. sw_gadfmt    dc.b    "Yes Sure|No Dump Them",0
  1731.         even
  1732. sw_tags        dc.l    RT_Window
  1733.         dc.l    0
  1734.         dc.l    TAG_END
  1735.         dc.l    0
  1736.  
  1737. * Clear Game Field Requester
  1738. clr_bodyfmt    dc.b    "You've Made Some Changes",10
  1739.         dc.b    "to this Game Field.",10
  1740.         dc.b    "CLEAR This Field ?",0
  1741. clr_gadfmt    dc.b    "Yes Sure|No Forget It",0
  1742.         even
  1743. clr_tags    dc.l    RT_Window
  1744.         dc.l    0
  1745.         dc.l    TAG_END
  1746.         dc.l    0
  1747.         even
  1748.  
  1749. * Get Game Time Requester
  1750. time_title    dc.b    "Enter Time Allowed",0
  1751.         even
  1752. time_data    dc.l    0
  1753. time_tags    dc.l    RT_Window
  1754.         dc.l    0
  1755.         dc.l    RTGL_Min
  1756.         dc.l    10
  1757.         dc.l    RTGL_Max
  1758.         dc.l    9999
  1759.         dc.l    RTGL_Width
  1760.         dc.l    200
  1761.         dc.l    TAG_END
  1762.         dc.l    0
  1763.  
  1764. * Get Game Target Requester
  1765. target_title    dc.b    "Enter Target",0
  1766.         even
  1767. target_data    dc.l    0
  1768. target_tags    dc.l    RT_Window
  1769.         dc.l    0
  1770.         dc.l    RTGL_Min
  1771.         dc.l    1
  1772.         dc.l    RTGL_Max
  1773.         dc.l    999
  1774.         dc.l    RTGL_Width
  1775.         dc.l    200
  1776.         dc.l    TAG_END
  1777.         dc.l    0
  1778.  
  1779. * Help Requester
  1780. help_bodyfmt    INCBIN    help_text
  1781.         dc.b    0
  1782. help_gadfmt    dc.b    "Great",0
  1783.         even
  1784. help_tags    dc.l    RT_Window
  1785.         dc.l    0
  1786.         dc.l    TAG_END
  1787.         dc.l    0
  1788.  
  1789. * Score Requester
  1790. score_bodyfmt    dc.b    "SCORE:",10
  1791.         dc.b    10
  1792.         dc.b    "You've Collected %d Diamonds.",10
  1793.         dc.b    "%d Were required.",10
  1794.         dc.b    "You've %d Time Units Left.",0
  1795. score_gadfmt    dc.b    "Ain't I Great",0
  1796.         even
  1797. score_tags    dc.l    RT_Window
  1798.         dc.l    0
  1799.         dc.l    TAG_END
  1800.         dc.l    0
  1801. score_args    dc.w    0
  1802.         dc.w    0
  1803.         dc.w    0
  1804.  
  1805. play_dir_tags    dc.l    RTFI_MatchPat
  1806.         dc.l    bd_wild_card
  1807.         dc.l    RTFI_Dir
  1808.         dc.l    play_directory,0
  1809.         dc.l    TAG_END
  1810.         dc.l    0
  1811.  
  1812. wild_tags    dc.l    RTFI_MatchPat
  1813.         dc.l    bd_wild_card
  1814.         dc.l    TAG_END
  1815.         dc.l    0
  1816.  
  1817. bd_wild_card    dc.b    '#?.bd',0
  1818.         even
  1819.  
  1820. play_directory    dc.b    'CAVES',0
  1821.         even
  1822.  
  1823. * Filenames and Name Buffers
  1824. filename    ds.b    112
  1825. play_filename    ds.b    112
  1826. completename    ds.b    224
  1827.         even
  1828. temp_file_name    dc.b    'ram:boulderdashtemp.bd',0
  1829.  
  1830.